package com.wyc.controller;

import com.wyc.service.PlantfromService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * @author juanbai
 */
@RestController
public class PlantfromController {

    @Autowired
    PlantfromService plantfromService;
    @Value("${platfrom.com_test}")
    String com;
    @Value("${platfrom.searchGroupList}")
    String searchGroupList;
    @Value("${platfrom.searchGroupCatalogList}")
    String searchGroupCatalogList;
    @Value("${platfrom.searchGroupResourceList}")
    String searchGroupResourceList;
    @Value("${platfrom.searchGroupResourceInfo}")
    String searchGroupResourceInfo;
    @Value("${platfrom.searchGroupForResourceList}")
    String searchGroupForResourceList;
    @Value("${platfrom.directoryCount}")
    String directoryCount;
    @Value("${platfrom.groupList}")
    String groupList;
    @Value("${platfrom.dataList}")
    String dataList;
    @Value("${platfrom.shareDataCount}")
    String shareDataCount;
    @Value("${platfrom.shareDataGroupList}")
    String shareDataGroupList;
    @Value("${platfrom.groupUseShareDataSetList}")
    String groupUseShareDataSetList;
    @Value("${platfrom.groupShareDataDescribe}")
    String groupShareDataDescribe;
    /**
     * 部门列表查询
     * @return
     */
    @RequestMapping(value = {"/searchgrouplist/{pageNo}/{pageSize}"},method = RequestMethod.GET)
    public String searchgrouplist(@PathVariable int pageNo,@PathVariable int pageSize){
        String url = com+searchGroupList+"?pageNo="+pageNo+"&pageSize="+pageSize+"&";
        Map<String,String> map = new HashMap();
        map.put("pageNo", String.valueOf(pageNo));
        map.put("pageSize", String.valueOf(pageSize));
        return plantfromService.getList(url,map);
    }

    /**
     * 部门数据目录列表查询
     * @return
     */
    @RequestMapping(value = {"/searchGroupCatalogList/{gid}"},method = RequestMethod.GET)
    public String searchGroupCatalogList(@PathVariable String gid){
        Map<String,String> map = new HashMap();
        map.put("gid",gid);
        return plantfromService.postList("gid="+gid,com+searchGroupCatalogList,map);
    }

    /**
     * 部门资源列表查询
     * @return
     */
    @RequestMapping(value = {"/searchGroupResourceList/{gid}/{nodeId}/{pageNo}/{pageSize}"},method = RequestMethod.GET)
    public String searchGroupResourceList(@PathVariable String gid,@PathVariable String nodeId,@PathVariable int pageNo,@PathVariable int pageSize){
        Map<String,String> map = new HashMap();
        map.put("gid",gid);
        map.put("nodeId",nodeId);
        map.put("pageNo", String.valueOf(pageNo));
        map.put("pageSize", String.valueOf(pageSize));
        return plantfromService.postList("gid="+gid+"&nodeId="+nodeId+"&pageNo="+pageNo+"&pageSize="+pageSize,com+searchGroupResourceList,map);
    }

    /**
     * 部门资源详情查询
     * @return
     */
    @RequestMapping(value = {"/searchGroupResourceInfo/{id}"},method = RequestMethod.GET)
    public String searchGroupResourceInfo(@PathVariable String id){
        String url = com+searchGroupResourceInfo+"?id="+id+"&";
        Map<String,String> map = new HashMap();
        map.put("id",id);
        return plantfromService.getList(url,map);
    }

    /**
     * 部门数据列表组合查询
     * @return
     */
    @RequestMapping(value = {"/searchGroupForResourceList/{id}/{nodeId}/{startdate}/{enddate}/{format}/{pageNo}/{pageSize}"},method = RequestMethod.GET)
    public String searchGroupForResourceList(@PathVariable String id,@PathVariable String nodeId,@PathVariable String startdate,@PathVariable String enddate,@PathVariable String format,@PathVariable int pageNo,@PathVariable int pageSize){
        String url = com+searchGroupForResourceList+"?id="+id
                +"&nodeId="+nodeId
                +"&startdate="+startdate
                +"&enddate="+enddate
                +"&format="+format
                +"&pageNo="+pageNo
                +"&pageSize="+pageSize+"&";
        Map<String,String> map = new HashMap();
        map.put("id",id);
        map.put("nodeId",nodeId);
        map.put("startdate",startdate);
        map.put("enddate",enddate);
        map.put("format",format);
        map.put("pageNo", String.valueOf(pageNo));
        map.put("pageSize", String.valueOf(pageSize));
        return plantfromService.getList(url,map);
    }

    /**
     * 省直共享目录数量
     * @return
     */
    @RequestMapping(value = {"/directoryCount"},method = RequestMethod.GET)
    public String directoryCount(){
        String url = com+directoryCount+"?";
        Map map = new HashMap();
        return plantfromService.getList(url,map);
    }

    /**
     * 省直部门列表
     * @return
     */
    @RequestMapping(value = {"/groupList"},method = RequestMethod.GET)
    public String groupList(){
        String url = com+groupList+"?";
        Map map = new HashMap();
        return plantfromService.getList(url,map);
    }

    /**
     * 省直部门数据列表
     * @return
     */
    @RequestMapping(value = {"/dataList/{gid}/{dirId}/{dirLv}/{pageSize}/{pageNo}"},method = RequestMethod.GET)
    public String dataList(@PathVariable String gid,@PathVariable Long dirId,@PathVariable int dirLv,@PathVariable int pageSize,@PathVariable int pageNo){
        String url = com+dataList
                +"?gid="+gid
                +"&dirId="+dirId
                +"&dirLv="+dirLv
                +"&pageSize="+pageSize
                +"&pageNo="+pageNo
                +"&";
        Map<String,String> map = new HashMap();
        map.put("gid",gid);
        map.put("dirId", String.valueOf(dirId));
        map.put("dirLv", String.valueOf(dirLv));
        map.put("pageSize", String.valueOf(pageSize));
        map.put("pageNo", String.valueOf(pageNo));
        return plantfromService.getList(url,map);
    }

    /**
     * 省直共享数据总量、文件类、接口类、交换库
     * @return
     */
    @RequestMapping(value = {"/shareDataCount"},method = RequestMethod.GET)
    public String shareDataCount(){
        String url = com+shareDataCount+"?";
        Map map = new HashMap();
        return plantfromService.getList(url,map);
    }

    /**
     * 数据共享省直部门列表
     * @return
     */
    @RequestMapping(value = {"/shareDataGroupList"},method = RequestMethod.GET)
    public String shareDataGroupList(){
        String url = com+shareDataGroupList+"?";
        Map map = new HashMap();
        return plantfromService.getList(url,map);
    }

    /**
     * 省直部门共享数据列表
     * @return
     */
    @RequestMapping(value = {"/groupUseShareDataSetList/{id}/{pageSize}/{pageNo}"},method = RequestMethod.GET)
    public String groupUseShareDataSetList(@PathVariable String id,@PathVariable String pageSize,@PathVariable String pageNo){
        String url = com+groupUseShareDataSetList
                +"?id="+id
                +"&pageSize="+pageSize
                +"&pageNo="+pageNo
                +"&";
        Map<String,String> map = new HashMap();
        map.put("id",id);
        map.put("pageSize",pageSize);
        map.put("pageNo",pageNo);
        return plantfromService.getList(url,map);
    }

    /**
     * 省直部门共享数据总汇
     * @return
     */
    @RequestMapping(value = {"/groupShareDataDescribe/{id}"},method = RequestMethod.GET)
    public String groupShareDataDescribe(@PathVariable String id){
        String url = com+groupShareDataDescribe
                +"?id="+id
                +"&";
        Map<String,String> map = new HashMap();
        map.put("id",id);
        return plantfromService.getList(url,map);
    }
}
